* Clear all data

clear all

set more off

* ===========================

* 1. SET FILE PATH HERE:

* ===========================

local path "C:\Users\icatovic\Downloads"   // <--- UPDATE THIS LINE ONLY

import excel "`path'/Right_to_Know_2023-033 -- Bet Methods by Game and Basket, MultiGame Baskets, 2021-03-31.xlsx", sheet("Right_to_Know_2023-033 -- Bet M") firstrow clear


*Exclude Keno Games
drop if Game == "KENO"

*Create a binary for Lotto games
gen Lotto = 1
replace Lotto = 0 if Game == "DPICK2" | Game == "DPICK3" | Game == "DPICK4" | Game == "DPICK5" | Game == "EPICK2" | Game == "EPICK3" | Game == "EPICK4" | Game == "EPICK5" 

*Isolate Manual vs QP
gen Manual = 1
replace Manual = 0 if BetMethod == "QuickPick-Keyed Bet" | BetMethod == "QuickPick-Playslip"

*Only keep observations for players who played both a Lotto and non-Lotto game
by SessionID, sort: egen mixed = mean(Lotto)
drop if mixed == 0
drop if mixed == 1

ssc install distinct
*34,184 unique session IDs with mixed games
distinct SessionID

bysort SessionID (Manual): egen consistent = mean(Manual)
egen tag = tag(SessionID)

*646 transactions consistently QP
count if consistent == 0 & tag
*9,922 transactions consistently MP
count if consistent == 1 & tag

gen ML = .
replace ML = 0 if Manual == 1 & Lotto == 0 
replace ML = 1 if Manual == 0 & Lotto == 1
replace ML = 2 if Manual == 0 & Lotto == 0
replace ML = 3 if Manual == 1 & Lotto == 1

by SessionID, sort: egen ddmax = max(ML)
by SessionID, sort: egen ddmin = min(ML)

*16,277 unique session IDs with mixed games only manual pick for numbers and QP for lotto
distinct SessionID if ddmin==0 & ddmax==1

*67 unique session IDs with mixed games only QP for numbers and manual pick for lotto
distinct SessionID if ddmin==2 & ddmax==3

